#include <iostream>
#include "gpioSwitch.h"
#include "TemHum.h"

using namespace std;

int main(int argc, const char *argv[])
{
	gpioSwitch relay(1);

    Am2322 am(7);
    am.read();
    cout << "当前温度：" << am.getTemperature() << endl;
    cout << "当前湿度：" << am.getHumidity() << endl;

	if(argc == 2)
	{
        if(*argv[1] == 'c')
        {
            cout << "input cycle mode" << endl;
            relay.setCycle(10);
        }
        else if(atoi(argv[1]) == 0)
		{
			cout << "Turn OFF the Switch" << endl;
			relay.set(OFF);
		}				
		else if(atoi(argv[1]) == 1)
		{
			cout << "Turn ON the Switch" << endl;
			relay.set(ON);
		}
	}
	else if(argc ==3)
	{
		relay.set(ON);

		if(*argv[1] == 's')
		{
			cout << "Set a delay second time..." << endl;
			relay.set(OFF,atoi(argv[2]));
		}
		else if(*argv[1] == 'm')
		{
			cout << "Set a delay minute time..." << endl;
			relay.set(OFF,atoi(argv[2]) * 60);
		}
	}


	return 0;
}
